package main.java.tmi.clearance.service.impl;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import main.java.tmi.common.service.impl.AbstractDao;
import main.java.tmi.clearance.service.ClearanceVO;

import org.springframework.stereotype.Repository;

/**
 * Asign Data Access Object
 *
 * @author min
 * @since 2010. 09. 10.
 */
@Repository
public class ClearanceDAO extends AbstractDao {
	
	public Map<String,String> getClearanceView(Map<String,String> param){
    	
    	Map<String,String> returnMap ;
    	if( param.get("clearNo").toString().equals("") ){
    		returnMap = (Map<String,String>) selectByPk("ClearanceDAO.getClearanceView2", param);
    	}else{
    		returnMap = (Map<String,String>) selectByPk("ClearanceDAO.getClearanceView", param);
    	}
        return returnMap;
    }
    
	

	//조회
	public List<ClearanceVO> getClearanceDetailList(Map<String,String> param) throws SQLException {
		
		List result;
		if( param.get("clearNo").toString().equals("") ){
			result = (List<ClearanceVO>) list("ClearanceDAO.getClearanceDetailList2", param);
		}else{
			result = (List<ClearanceVO>) list("ClearanceDAO.getClearanceDetailList", param);
		}
		
		return result ;
	}
	
	
	public String  addClearance(Map<String, String> param) throws SQLException {
		return insert("ClearanceDAO.addClearance", param).toString();
	}
	
	
	public int  modifyClearance(Map<String, String> param) throws SQLException {
		return update("ClearanceDAO.modifyClearance", param);
	}
	

    //등록
	public int addClearanceDetail(Map<String, String> param) throws SQLException {
		System.out.println("==================================addclearanceDetail param"+param );
		insert("ClearanceDAO.addClearanceDetail", param);
		return 1;
	}
	
	//수정
	public int  clearanceDetailUpdate(Map<String, String> param) throws SQLException {
		return update("ClearanceDAO.clearanceDetailUpdate", param);
	}
	
	//확정
    public int  confirmPacking(Map<String, String> param) throws SQLException {
        return update("ClearanceDAO.confirmPacking", param);
    }
    
	
	public int  deleteDoDep(Map<String, String> param) throws SQLException {
		return delete("ClearanceDAO.deleteDoDep", param);
	}
	
	public int  deleteDoHead(Map<String, String> param) throws SQLException {
		return delete("ClearanceDAO.deleteDoHead", param);
	}
	
	//확정
    public int  noConfirmPacking(Map<String, String> param) throws SQLException {
        return update("ClearanceDAO.noConfirmPacking", param);
    }
}
